﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestThrift.Interface;
using Thrift;
using Thrift.Protocol;
using Thrift.Server;
using Thrift.Transport;

namespace Thrift.Server
{
    class Program
    {
        static void Main(string[] args)
        {
            int port = 8086;
            //设置服务端口为8088
            TServerSocket serverTransport = new TServerSocket(port);
            //设置传输协议工厂
            TBinaryProtocol.Factory factory = new TBinaryProtocol.Factory();
            //关联处理器与服务的实现
            TProcessor processor = new TestService.Processor(new TestsService());
            //创建服务端对象
            TServer server = new TThreadPoolServer(processor, serverTransport, new TTransportFactory(), factory);
            try
            {
                Console.WriteLine(string.Format("C# ThriftServer listening {0} port", port));
                server.Serve();
            }
            catch (TTransportException ex)
            {
                //打印异常信息
                Console.WriteLine(ex);
                Console.ReadLine();
            }
        }
    }
}
